package atom.core0.concurrent;
/**
 * Title: 多个信号量的管理
 * Description:
 * Copyright: Copyright (c) 2010
 * @author hike_man@126.com
 * @version 1.0
 */
import java.util.HashMap;

public class MySemaphoreManager
{
    private static MySemaphoreManager instance = new MySemaphoreManager();
    private static HashMap mySemaphoreMap = new HashMap();
    public static MySemaphoreManager getInstance() 
    {
        return instance;
    }
    public void setMySemaphoreCount(String sFrontNo,int iMaxCount)
    {
    	MySemaphore mySemaphore;
    	mySemaphore = (MySemaphore)mySemaphoreMap.get(sFrontNo);
    	if (mySemaphore==null)
    	{
    		mySemaphore = new MySemaphore(iMaxCount);
    		mySemaphoreMap.put(sFrontNo, mySemaphore);
    	}
    	else
    		mySemaphore.setCount(iMaxCount);
    }
    public MySemaphore getMySemaphore(String sFrontNo)
    {
    	MySemaphore mySemaphore;
    	mySemaphore = (MySemaphore)mySemaphoreMap.get(sFrontNo);
    	return mySemaphore;
    }

}
//使用方法
//一次设置
//MySemaphoreManager.getInstance().setMySemaphoreCount("front1_0",10);
//多次使用
//MySemaphoreManager.getInstance().getMySemaphore("front1_0").acquire;
//MySemaphoreManager.getInstance().getMySemaphore("front1_0").release();
//渠道线程池命名规则
//实时交易的front1_0 批量交易 查询 协议的front1_1


